import { SingleInstance } from "./singleinstance";

async function run (){
    
    const driver = SingleInstance.create_driver();

    await driver.get("https://www.baidu.com/");
    const input = await driver.findElement({css:'#kw'});
    await input.sendKeys("helloworld");

    const btn = await driver.findElement({css:'#su'});
    await btn.click();

    await driver.sleep(2000);
    const res = await driver.findElement({css:'div[id="1"]>h3>a'});
    await res.click();

    // 切换窗口
    const allwindows = await driver.getAllWindowHandles();
    await driver.switchTo().window(allwindows[1]);

    const baikeInput = await driver.findElement({css:'#query'});
    await baikeInput.clear();
    await baikeInput.sendKeys("hahahah");
}

run();